#include "header.h"

int encrypt(char *filename)
{
	int ret = SUCCESS;
	char command[MAX_COMMAND_LEN];
	char newFile[MAX_FILENAME_LEN];
	char finalFile[MAX_FILENAME_LEN];

	//encrypt file
	strcpy(newFile, filename);
	newFile[strlen(filename)-4] = '\0';
	
	strcpy(command, "tar -xvf ");
	strcat(command, filename);
	strcat(command, " ");
	strcat(command, newFile);

	ret = system(command);
	if (FAILURE == ret) {
		printf("Unable to decompress file : %s\n", filename);
	}

	strcpy(finalFile, newFile);
	strcat(finalFile, ".b64");

	ret = rename(newFile, finalFile);
	if (FAILURE == ret) {
		printf("Unable to rename filename\n");
	}

	return ret;
}

